/**
 * 1
 *  
 * @Author : roryrywang
 * @DateTime : 24-8-29 下午3:51
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

string change(string s) {
    string res = "";
    int cnt_ = 0;
    int cntA = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '_') {
            if (i == 0 || i == s.size() - 1 || s[i - 1] == '_') return "indistinct";
            cnt_++;
        }
        if (s[i] >= 'A' && s[i] <= 'Z') {
            if (i == 0) return "indistinct";
            cntA++;
            res += '_';
            res += (char) (s[i] - 'A' + 'a');
        } else {
            res += s[i];
        }
    }
    if (cnt_ > 0 && cntA > 0) return "indistinct";
    return res;
}

int main() {
    int n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        cout << change(s) << endl;
    }
    return 0;
}